#pragma once
#include<iostream>
#include<string>
#include"InetAddr.hpp"
//基类，文件做统一管理listener继承。
//封装每一个类，保证fd有各自的io缓冲区
class Reactor;
class Channel;
 
using handler_t=std::function<std::string(std::string)>;
class Connection
{
public:
    Connection():
    _event(0),
    _owner(nullptr)
    {}
    ~Connection(){}

    void SetEvent(const uint32_t event)  {  _event=event; }
    uint32_t GetEvent()  { return _event;}

    void SetOwner(Reactor* tsv)
    {
        _owner=tsv;
    }
    Reactor* GetOwner(){return _owner;}
private:
  
    //回指指针
    Reactor *_owner;
    //对应关心的事件
    uint32_t _event;
public:
    handler_t _handler;
public:
    virtual void Sender()=0;
    virtual void Recver()=0;
    virtual void Excepter()=0;
    virtual int GetSockFd()=0;
    void RegistHandler(handler_t handler)
    {
        _handler=handler;
    }
};